{extends file="main.tpl"}
{block name=head}
<script type="text/javascript">
  $(document).ready(function() {
    $('.billDetailId').focus();
  });
function myFunction()
{
  if(confirm("You Want To Remove This Record")== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}
</script>
<script type="text/javascript">
  $(document).ready(function() {
    $('.billMasterId').focus();
  });
function myFunction()
{
  if(confirm("You Want To Remove This Record")== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}
</script>
<script type="text/javascript">
$(document).ready(function(){
 });

function setTotatOfEach()
{
	var setTotal = 0;
	
	$('.outAmount').each(function(i)
  {
    outAmount = $(this).val();
    if (!isNaN(outAmount)) setTotal += Number(outAmount);
  });
  $('#total').val(parseFloat(setTotal).toFixed(2));
  
  var netTotal = setTotal + parseFloat($("#serviceTax").val()) + parseFloat($("#roundOff").val());
  
  $('#netTotal').val(parseFloat(netTotal).toFixed(2));
}
function calcTaxRate(theTaxPercentage)
{
	var percentageTax = parseFloat($(theTaxPercentage).val());
	var taxOnAmount = parseFloat($('#total').val());
	var serviceTax = (percentageTax * taxOnAmount) / 100;
	$('#serviceTax').val(parseFloat(serviceTax).toFixed(2));
	setTotatOfEach();
}
</script>
{/block}
{block name=body}
<span style="float:left;"><button onclick="window.close();">Close</button></span>
<span style="float:left;"><a href="billListPdf.php?billMasterId={$masterArray.billMasterId}">Print</a></span>
<table align="center" border="0" cellpadding="2" cellspacing="2" >
<tr><td align="center" class="table1" colspan="12">Bill Detail</td></tr>
<tr>
	<td align="center" class="table1" colspan="0"></td>
	<td align="center" class="table1" colspan="0"></td>
	<td align="center" class="table1" colspan="3">Party</td>
	<td align="center" class="table1" colspan="3">Bill Memo</td>
	<td align="center" class="table1" colspan="3">Memo Date</td>
</tr>
<tr>
  <td align="center" class="table2">
		<a href="billEditMaster.php?billMasterId={$masterArray.billMasterId}"><img src="./images/b_edit.png"></a>
	</td>
	<td class="table2" align="center">
	  <a href="billDetailDelete.php?billMasterId={$masterArray.billMasterId}" onclick="return myFunction();" class="link"><img src="./images/deleteIco.png"></a></td>	  
	<td align="center" class="table2" colspan="3">{$masterArray.partyName}</td>
	<td align="center" class="table2" colspan="3">{$masterArray.billNo}</td>
	<td align="center" class="table2" colspan="3">{$masterArray.billDate}</td>
</tr>
<tr><td align="center" colspan="12"><hr></td></tr>
<tr>
	<td align="center" class="table1"></td>
	<td align="center" class="table1"></td>
	<td align="center" class="table1">Out. Date</td>
	<td align="center" class="table1">Out. Challan</td>
	<td align="center" class="table1">In. Challan</td>
	<td align="center" class="table1">Material</td>
	<td align="center" class="table1">Final Process</td>
	<td align="center" class="table1">Weight</td>
	<td align="center" class="table1">Quantity</td>
	<td align="center" class="table1">Rate</td>
	<td align="center" class="table1">Amount</td>
</tr>
{section name=sec loop=$detailArray}
<tr>
  <td align="center" class="table2">
		<a href="billEditDetail.php?billDetailId={$detailArray[sec].billDetailId}"><img src="./images/b_edit.png"></a>
  </td>
  <td class="table2" align="center">
    <a href=billDetailDelete.php?billDetailId={$detailArray[sec].billDetailId}&billMasterId={$detailArray[sec].billDetailId} onclick="return myFunction();" class="link"><img src="./images/deleteIco.png"></a>
	</td>
	<td align="center" class="table2">{$detailArray[sec].outDate}</td>
	<td align="center" class="table2">{$detailArray[sec].outChallenNo}</td>
	<td align="center" class="table2">{$detailArray[sec].inChallenNo}</td>
	<td align="center" class="table2">{$detailArray[sec].materialName}</td>
	<td align="center" class="table2">{$detailArray[sec].finalProcess}</td>
	<td align="right" class="table2">{$detailArray[sec].outQuantity}</td>
	<td align="right" class="table2">{$detailArray[sec].outWieght}</td>
	<td align="right" class="table2">{$detailArray[sec].outRate}</td>
	<td align="right" class="table2">{$detailArray[sec].amount}</td>
</tr>
{/section}
<tr>
	<td align="right" class="table1" colspan="9">Sub Total</td>
	<td align="center" class="table2">:</td>
	<td align="right" class="table2" >{$totalAmm}</td>
	</td>
</tr>
<tr>
	<td align="right" class="table1" colspan="9">Service Tax + Edu. Cess</td>
	<td align="center" class="table2">{$allTax} %</td>
	<td align="right" class="table2">{$serviceTax}</td>
</tr>
<tr>
	<td align="right" class="table1" colspan="9">Round Off</td>
	<td align="center" class="table2">:</td>
	<td align="right" class="table2">{$roundOff}</td>
</tr>
<tr>
	<td align="right" class="table1" colspan="9">Net Total</td>
	<td align="center" class="table2">:</td>
	<td align="right" class="table1">{$netTotal}</td>
</tr>
</table>
{/block}